package com.wuchao.service.serviceimpl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.wuchao.entity.Entry;
import com.wuchao.mapper.EntryMapper;
import com.wuchao.service.EntryService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Author wuchao66
 * @Date 2023/9/21 15:32
 * @PackageName:com.wuchao.service.serviceimpl
 * @ClassName: EntryServiceImpl
 * @Description: TODO
 * @Param
 * @Version 1.0
 */
@Service
public class EntryServiceImpl implements EntryService {
     @Resource //自动注入
    EntryMapper entryMapper;//容器
    @Override
    public List<Entry> findEntryById(int id) {
        return entryMapper.findEntryById(id);
    }
//spring整合了，就是抱着mapper玩
    @Override
    public PageInfo<Entry> findByPage1(int categoryId, String title, Integer currentPage, Integer pageSize) {
        PageHelper.startPage(currentPage,pageSize);
        return new PageInfo<Entry>(entryMapper.findEntryAndCateGoryByCategoryIdByConcatTitleByPage(categoryId,title));
    }

    @Override
    public int registerbyname(String title) {
        return entryMapper.registerbyname(title);
    }

    @Override
    public List<Entry> findEntryBycategoryId(int categoryId) {
        return entryMapper.findEntryBycategoryId(categoryId);
    }

    @Override
    public int loadbyEntry(String title, String summary) {
        return entryMapper.loadbyEntry(title, summary);
    }

    @Override
    public int addEntryByEntry(Entry entry) {
        return entryMapper.addEntryByEntry(entry);
    }


}
